package com.nbsaas.boot.manufacturing.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "工作中心", model = "工作中心")
@Entity
@Table(name = "bs_work_center")
@Comment("工作中心表")
public class WorkCenter extends AbstractEntity {

    @Comment("工作中心编码")
    @SearchItem(name = "workCenterCode", key = "workCenterCode", label = "工作中心编码")
    @FormField(title = "工作中心编码", sortNum = "1", grid = true, required = true)
    @Column(length = 50, nullable = false, unique = true)
    private String workCenterCode;

    @Comment("工作中心名称")
    @SearchItem(name = "name", key = "name", label = "工作中心名称")
    @FormField(title = "工作中心名称", sortNum = "2", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("工作中心类型")
    @FormField(title = "工作中心类型", sortNum = "3", grid = true, type = InputType.select)
    @Column(length = 50)
    private String workCenterType; // MACHINING-机加工, ASSEMBLY-装配, WELDING-焊接, PAINTING-喷涂, TESTING-检测

    @Comment("所属车间ID")
    @FormField(title = "所属车间", sortNum = "4", grid = true, type = InputType.select)
    private Long workshopId;

    @Comment("负责人")
    @FormField(title = "负责人", sortNum = "5", grid = true)
    private Long manager;

    @Comment("工作中心描述")
    @FormField(title = "工作中心描述", sortNum = "6", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String description;

    @Comment("标准工时费率")
    @FormField(title = "标准工时费率", sortNum = "7", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal standardHourRate;

    @Comment("准备工时费率")
    @FormField(title = "准备工时费率", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal setupHourRate;

    @Comment("设备利用率(%)")
    @FormField(title = "设备利用率(%)", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(precision = 5, scale = 2)
    private BigDecimal equipmentUtilization;

    @Comment("人员利用率(%)")
    @FormField(title = "人员利用率(%)", sortNum = "10", grid = true, type = InputType.el_input_number)
    @Column(precision = 5, scale = 2)
    private BigDecimal laborUtilization;

    @Comment("工作中心状态")
    @FormField(title = "工作中心状态", sortNum = "11", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // ACTIVE-启用, INACTIVE-停用, MAINTENANCE-维护

    @Comment("是否关键工作中心")
    @FormField(title = "是否关键工作中心", sortNum = "12", grid = true, type = InputType.select)
    private Boolean isCritical;

    @Comment("生产能力(件/小时)")
    @FormField(title = "生产能力(件/小时)", sortNum = "13", grid = true, type = InputType.el_input_number)
    private Integer productionCapacity;

    @Comment("最大批量")
    @FormField(title = "最大批量", sortNum = "14", grid = true, type = InputType.el_input_number)
    private Integer maxBatchSize;

    @Comment("最小批量")
    @FormField(title = "最小批量", sortNum = "15", grid = true, type = InputType.el_input_number)
    private Integer minBatchSize;

    @Comment("工作中心面积(平方米)")
    @FormField(title = "工作中心面积(平方米)", sortNum = "16", grid = true, type = InputType.el_input_number)
    private Integer area;

    @Comment("工作中心位置")
    @FormField(title = "工作中心位置", sortNum = "17", grid = true)
    @Column(length = 200)
    private String location;

    @Comment("联系电话")
    @FormField(title = "联系电话", sortNum = "18", grid = true)
    @Column(length = 50)
    private String contactPhone;

    @Comment("技术参数")
    @FormField(title = "技术参数", sortNum = "19", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String technicalParameters;

    @Comment("安全要求")
    @FormField(title = "安全要求", sortNum = "20", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String safetyRequirements;

    @Comment("环境要求")
    @FormField(title = "环境要求", sortNum = "21", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String environmentalRequirements;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "22", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 